<?php
/**
 * Created by IntelliJ IDEA.
 * User: liuxin
 * Date: 2018/7/20
 * Time: 下午3:34
 */

namespace app\admin\model;
use think\Model;

class User extends Base
{
    public function login($username, $password)
    {

        $data['username'] = $username;
        $info = $this->where($data)->find();

        if ($info) {
            if (md5($password) == $info['password']) {
                session('user',$info);
                return $info;
            } else {
                $this->error  = '密码错误';
            }
        }else{
            $this->error  = '用户不存在';
        }
    }
}